/**
 * Created by bob on 14-2-17.
 */
//var reg = /(\w+\d+?):\n?(.*?):\s*?(http:\/\/.*)/gi;
var reg = /((\w+\d)+?:\n)?(.*?):\s*?(http:\/\/.*)/gi;
var fs = require('fs');
//var fileName = './guijiaoqi_s1.txt';
//var fileName = './guijiaoqi_s2.txt';
//var fileName = './guijiaoqi_s3.txt';
var fileName = './guijiaoqi_s4.txt';
var wxParser = require('./weixinParser');
//var writeTo = "./dest/鬼脚七第一季[做自己]/";
//var writeTo = "./dest/鬼脚七第二季[爱生活]/";
//var writeTo = "./dest/鬼脚七第三季/";
var writeTo = "./dest/鬼脚七第四季/";
//fs.readFile(fileName, {encoding: 'utf-8'}, function (err, data) {
//    if (err) throw err;
//    var match;
//    var prefix;
//    var parseFun = function () {
//        if ((match = reg.exec(data)) !== null) {
////            console.log(match);
//            prefix = match[2]?match[2]+"-":prefix;
//            var url = match[4];
//            var title = match[3];
//            title = (title.indexOf(prefix)===0?title:prefix+title)
//            console.log('准备离线['+title+"]");
////            var defer = new require('node-jquery').Deferred();
//            var defer = wxParser.parseWeixin(url, writeTo, prefix);
//            defer.done(function () {
//                console.log("["+title+"]离线完成！");
//                parseFun();
//            });
////            defer.resolve();
//        }
//    };
//    parseFun();
//});

var url = 'http://mp.weixin.qq.com/s?__biz=MjM5OTM3NjIyMA==&amp;mid=200314983&amp;idx=1&amp;sn=b194fbf73d8c3271d673b7dd103470d6#rd';
wxParser.parseWeixin(url,writeTo,'451-');